package cn.com.coding.system.dao;

import cn.com.coding.system.domin.UserCollectEntity;
import cn.com.coding.system.domin.dto.UserCollectDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * 用户收藏
 *
 * @author mxz
 * @email codingce@gmail.com
 * @date 2021-07-08 21:25:22
 */
@Mapper
public interface UserCollectDao extends BaseMapper<UserCollectEntity> {

    @Select("SELECT DISTINCT\n" +
            "gi.pid AS product_pid,\n" +
            "uct.user_pid as user_pid,\n" +
            "uct.pid,\n" +
            "uct.collect_status,\n" +
            "gi.product_name,\n" +
            "gi.des,\n" +
            "gi.price,\n" +
            "gi.real_price,\n" +
            "gi.category_pid,\n" +
            "uct.create_time,\n" +
            "uct.update_time \n" +
            "FROM\n" +
            "user_collect uct\n" +
            "LEFT JOIN product_info gi ON uct.product_pid = gi.pid\n" +
            "LEFT JOIN user_info ui ON uct.user_pid = ui.pid \n" +
            "WHERE\n" +
            "ui.pid = #{userPid}")
    Set<UserCollectDto> getUserCollectByUserPid(@Param("userPid") String userPid);
}
